home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / pp / pp-6.0 / Lib / format / reprecip2rfc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-18  |  3.6 KB  |  164 lines

  1. /* reprecip2rfc.c - Converts a Rrseq struct into a RFC string */
  2.  
  3. # ifndef lint
  4. static char Rcsid[] = "@(#)$Header: /xtel/pp/pp-beta/Lib/format/RCS/reprecip2rfc.c,v 6.0 1991/12/18 20:22:06 jpo Rel $";
  5. # endif
  6.  
  7. /*
  8.  * $Header: /xtel/pp/pp-beta/Lib/format/RCS/reprecip2rfc.c,v 6.0 1991/12/18 20:22:06 jpo Rel $
  9.  *
  10.  * $Log: reprecip2rfc.c,v $
  11.  * Revision 6.0  1991/12/18  20:22:06  jpo
  12.  * Release 6.0
  13.  *
  14.  */
  15.  
  16.  
  17.  
  18. #include        "util.h"
  19. #include        <isode/cmd_srch.h>
  20. #include    "dr.h"
  21.  
  22.  
  23. extern CMD_TABLE
  24.         rr_rcode [/* reason-codes */],
  25.         rr_dcode [/* diagnostic-codes */];
  26.  
  27. extern UTC    utclocalise();
  28. extern int    x400eits2rfc();
  29. static int    lastrace2rfc ();
  30.  
  31. /* ---------------------  Begin  Routines  -------------------------------- */
  32.  
  33.  
  34.  
  35.  
  36. int reprecip2rfc (rp, ap, buffer)  /* ReportedRecipientInfo -> RFC */
  37. Rrinfo    *rp;
  38. ADDR    *ap;
  39. char    *buffer;
  40. {
  41.     int     i;
  42.     char     *cp;
  43.  
  44.     if (rp == NULL)
  45.         return OK;
  46.  
  47.     cp = buffer;
  48.  
  49.     if (rp -> rr_recip) {
  50.         (void) sprintf (cp, "%s; ", ap -> ad_r822adr);
  51.         cp += strlen(cp);
  52.     }
  53.     else {
  54.         *buffer = '\0';
  55.         return OK;
  56.     }
  57.  
  58.     if (lastrace2rfc (rp, cp) == NOTOK)
  59.         return NOTOK;
  60.  
  61.     cp += strlen(cp);
  62.  
  63.     (void) sprintf (cp, "ext %d ", ap -> ad_extension);
  64.     cp += strlen(cp);
  65.  
  66.     i = mem2prf (ap -> ad_resp, ap -> ad_mtarreq, ap -> ad_usrreq);
  67.     (void) sprintf (cp, "flags %02d", i);
  68.     cp += strlen(cp);
  69.  
  70.     if (rp -> rr_originally_intended_recip &&
  71.         rp -> rr_originally_intended_recip->fn_addr) {
  72.         (void) sprintf (cp, " intended %s",
  73.                 rp -> rr_originally_intended_recip -> fn_addr);
  74.         cp += strlen(cp);
  75.     }
  76.  
  77.     if (rp -> rr_supplementary) {
  78.         (void) sprintf (cp, " info %s", rp->rr_supplementary);
  79.         cp += strlen(cp);
  80.     }
  81.     else if (rp -> rr_report.rep_type == DR_REP_FAILURE) {
  82.         (void) sprintf (cp, " info %s",
  83.             "Extra information on the failure was not supplied");
  84.         cp += strlen(cp);
  85.     }
  86.     PP_DBG (("Lib/rri2rfc returns (%s)", buffer));
  87.  
  88.     return OK;
  89. }
  90.  
  91. static int lastrace2rfc (rp, buffer)   /* LastTraceInformation -> RFC */
  92. Rrinfo    *rp;
  93. char            *buffer;
  94. {
  95.     Delinfo         *dliv;
  96.     NonDelinfo      *ndliv;
  97.     char            tbuf [BUFSIZ];
  98.     UTC        lut;
  99.     char    *cp = buffer;
  100.  
  101.     switch (rp -> rr_report.rep_type) {
  102.     case DR_REP_SUCCESS:
  103.         dliv = &rp -> rr_report.rep.rep_dinfo;
  104.         if (dliv->del_time == NULLUTC) {
  105.             PP_LOG(LLOG_EXCEPTIONS,
  106.                    ("lastrace2rfc: missing deliv time"));
  107.             return NOTOK;
  108.         }
  109.         lut = utclocalise(dliv -> del_time);
  110.         if(UTC2rfc (lut, tbuf) == NOTOK) {
  111.             PP_LOG(LLOG_EXCEPTIONS,
  112.                    ("lastrace2rfc: bad deliv time"));
  113.             return NOTOK;
  114.         }
  115.         free((char *) lut);
  116.         (void) sprintf (cp, "SUCCESS %s; %d; ",
  117.                 tbuf, dliv -> del_type);
  118.         break;
  119.     case DR_REP_FAILURE:
  120.         ndliv = &rp -> rr_report.rep.rep_ndinfo;
  121.         (void) sprintf (cp, "FAILURE %d (%s); %d (%s); ",
  122.             ndliv -> nd_rcode,
  123.             rcmd_srch (ndliv -> nd_rcode, rr_rcode),
  124.             ndliv -> nd_dcode,
  125.             rcmd_srch (ndliv -> nd_dcode, rr_dcode));
  126.         break;
  127.     default:
  128.         PP_LOG (LLOG_EXCEPTIONS,
  129.             ("Lib/lastrace2rfc/Unknown report type %d",
  130.             rp -> rr_report.rep_type));
  131.         *buffer = '\0';
  132.         return NOTOK;
  133.     }
  134.     cp += strlen(cp);
  135.  
  136.  
  137.     if (rp -> rr_arrival == NULLUTC) {
  138.         PP_LOG(LLOG_EXCEPTIONS,
  139.                ("lastrace2rfc: missing arrival time"));
  140.         return NOTOK;
  141.     }
  142.     lut = utclocalise (rp -> rr_arrival);
  143.     if(UTC2rfc (lut, tbuf) == NOTOK) {
  144.         PP_LOG (LLOG_EXCEPTIONS, ("lastrace2rfc: bad arrival time"));
  145.         return NOTOK;
  146.     }
  147.     free ((char *) lut);
  148.  
  149.     (void) sprintf (cp, "%s;", tbuf);
  150.     cp += strlen(cp);
  151.  
  152.     if (rp -> rr_converted) {
  153.         tbuf[0] = NULL;
  154.         if (x400eits2rfc (rp -> rr_converted,
  155.                   tbuf) == NOTOK)
  156.             return NOTOK;
  157.         if (tbuf[0])
  158.             (void) sprintf (cp, " converted(%s);", tbuf);
  159.     }
  160.     PP_DBG (("Lib/lastrace2rfc returns (%s)", buffer));
  161.  
  162.     return OK;
  163. }
  164.